# -*- coding: utf-8 -*-
from django.contrib import admin
from getdebt.main.models import Status, OPF, Sector, City, Contragent, Firm, Individual, Debt, Verdict, Currency
from getdebt.sell.models import Rating, Bid
from getdebt.advice.models import Event, Advice

class StatusAdmin(admin.ModelAdmin):
    fieldsets = [(None,{'fields': ('name','code')})]
    list_display = ('name','code')
    ordered = ('name')
admin.site.register(Status, StatusAdmin)

class CurrencyAdmin(admin.ModelAdmin):
    fieldsets = [(None,{'fields': ('name','code')})]
    list_display = ('name','code')
    ordered = ('name')
admin.site.register(Currency, CurrencyAdmin)

class OPFAdmin(admin.ModelAdmin):
    fieldsets = [(None,{'fields': ('name','nameshort')})]
    list_display = ('name','nameshort')
    ordered = ('name')
admin.site.register(OPF, OPFAdmin)

class SectorAdmin(admin.ModelAdmin):
    fieldsets = [(None,{'fields': ('name',)})]
    list_display = ('name',)
    ordered = ('name',)
admin.site.register(Sector, SectorAdmin)

class CityAdmin(admin.ModelAdmin):
    fieldsets = [(None,{'fields': ('name',)})]
    list_display = ('name',)
    ordered = ('name')
admin.site.register(City, CityAdmin)

class ContragentAdmin(admin.ModelAdmin):
    fieldsets = (
        ('Системные',{'fields': ('user','status','rec_date')}),
        ('Контакты', {'fields': ('city','address','tel1','tel2','contact')}))
    list_display = ('status','rec_date', 'city','address','tel1','contact','id')
    search_fields = ('contact',)
    list_filter = ('status','city')
    ordered = ('-rec_date')
admin.site.register(Contragent, ContragentAdmin)

class FirmAdmin(admin.ModelAdmin):
    fieldsets = (
        ('Контрагент системные',{'fields': ('user','status','rec_date')}),
        ('Контрагент контакты', {'fields': ('city','address','tel1','tel2','contact')}),
        ('Фирма', {'fields': ('name','inn','opf','sector','bankr','site','email','post')}))
    list_display = ('status', 'name','inn','city','address','bankr','tel1','post','contact','id')
    search_fields = ('name','inn','contact')
    list_filter = ('status','city','sector','bankr')
    ordered = ('-rec_date')
admin.site.register(Firm, FirmAdmin)

class IndividualAdmin(admin.ModelAdmin):
    fieldsets = (
        ('Контрагент системные',{'fields': ('user','status','rec_date')}),
        ('Контрагент контакты', {'fields': ('city','address','tel1','tel2','contact')}),
        ('Физическое лицо', {'fields': ('ip','fio','inn','email')}))
    list_display = ('status', 'fio','city','address','tel1','inn','contact','id')
    search_fields = ('fio','inn','contact')
    list_filter = ('status','city')
    ordered = ('-rec_date')
admin.site.register(Individual, IndividualAdmin)

class DebtAdmin(admin.ModelAdmin):
    fieldsets = (
        ('Системные',{'fields': ('user','tested','paid','rec_date','result')}),
        ('Основные', {'fields': ('date','debtor','creditor','summa','penalty','currency','genesis','state','agree')}))
    list_display = ('rec_date','debtor','creditor','summa','penalty','date','paid','tested')
    search_fields = ('debtor','creditor','genesis', 'state')
    list_filter = ('tested',)
    ordered = ('-rec_date')
admin.site.register(Debt, DebtAdmin)

class VerdictAdmin(admin.ModelAdmin):
    fieldsets = (
        ('Системные',{'fields': ('user','debt','inforce','rec_date','date','summa','penalty','currency')}),
        ('Описание', {'fields': ('resolution',)}))
    list_display = ('debt','inforce','rec_date','date','summa','penalty','currency')
    search_fields = ('resolution',)
    list_filter = ('inforce',)
    ordered = ('-rec_date')
admin.site.register(Verdict, VerdictAdmin)

class RatingAdmin(admin.ModelAdmin):
    fieldsets = (
        ('Системные',{'fields': ('user','debt','rec_date','summa','penalty','currency')}),
        ('Условия', {'fields': ('terms',)}))
    list_display = ('debt','rec_date','summa','penalty','currency')
    search_fields = ('terms',)
    ordered = ('-rec_date')
admin.site.register(Rating, RatingAdmin)

class BidAdmin(admin.ModelAdmin):
    fieldsets = (
        ('Системные',{'fields': ('user','debt','rec_date','summa','penalty','currency')}),
        ('Описание', {'fields': ('comment',)}))
    list_display = ('user','debt','rec_date','summa','penalty','currency')
    search_fields = ('comment',)
    ordered = ('-rec_date')
admin.site.register(Bid, BidAdmin)

class EventAdmin(admin.ModelAdmin):
    fieldsets = [(None,{'fields': ('name','code')})]
    list_display = ('name','code')
    ordered = ('name')
admin.site.register(Event, EventAdmin)

class AdviceAdmin(admin.ModelAdmin):
    fieldsets = [(None,{'fields': ('event','sort', 'title', 'content')})]
    list_display = ('event','sort', 'title', 'content')
    ordered = ('event')
admin.site.register(Advice, AdviceAdmin)
